﻿namespace NiYo.ParserBuilder.Domain.Hl7.DataTypes
{
    /// <summary>
    /// HD
    /// </summary>
    public class HierarchicDesignator : Hl7DataType
    {
        /// <summary>
        /// Used as the hl7 identifier for the user-defined table of values for this component.
        /// Standard HL7 position: 1
        /// </summary>
        public string NameSpaceId { get; set; }

        /// <summary>
        /// Universal Id.
        /// Standard HL7 position: 2
        /// </summary>
        public string UniversalId { get; set; }

        /// <summary>
        /// Universal Id Type.
        /// Standard HL7 position: 3
        /// </summary>
        public string UniversalIdType { get; set; }

        #region - Helper Methods -

        /// <summary>
        /// To compare current HierarchicDesignator with another HierarchicDesignator
        /// </summary>
        /// <returns></returns>
        protected bool Equals(HierarchicDesignator other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other.NameSpaceId, NameSpaceId) && Equals(other.UniversalId, UniversalId) && Equals(other.UniversalIdType, UniversalIdType);
        }

        /// <summary>
        /// To compare current HierarchicDesignator with another object
        /// </summary>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof(HierarchicDesignator)) return false;
            return Equals((HierarchicDesignator)obj);
        }

        /// <summary>
        /// Used by Equals method to compare objects
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            unchecked
            {
                var result = (NameSpaceId != null ? NameSpaceId.GetHashCode() : 0);
                result = (result * 397) ^ (UniversalId != null ? UniversalId.GetHashCode() : 0);
                result = (result * 397) ^ (UniversalIdType != null ? UniversalIdType.GetHashCode() : 0);
                return result;
            }
        }

        #endregion
    }
}
